
var codedata = {
    "validatecodeflag": false,
    "phonecodeflag": false
}

/// <reference path="layer-v1.8.5/layer/layer.min.js" />
//======================提示框================
var TipMsg = {
    showTimer: null,
    popUp: function (icon, msg, abort, callback) {/*true或false,"提示",true为有取消按钮*/
        var cName;
        var callback = callback || function () { };
        if (icon == true) { cName = "true" }
        else if (icon == false) { cName = "false" } else { cName = "hide" }
        $("body").append('<div id="mark"></div><div id="alert"><h3>Tips<a href="javascript:;" onclick="TipMsg.closePop()"></a></h3><div class="tip_msg"><i class="' + cName + '"></i><div class="msg_con">' + msg + '</div></div><div class="al_btn"><button id="config">确定</button><button onclick="TipMsg.closePop()" id="abort">取消</button></div></div>');
        if (abort == true) { $("#abort").show(); }
        var win = $(window), off = $("#alert");
        off.css({ "left": (win.width() - off.width()) / 2 });
        $("#config").click(function () {
            TipMsg.closePop(callback);
        });
    },
    closePop: function (callback) {
        $("#mark,#alert").remove();
        if (callback) { callback(); }
    },
    position: function (msg, tag, timer, leftplus, topplus, direction) {/*"提示",$(this),2000,向左偏移,向上偏移,方向*/
        clearTimeout(this.showTimer);
        if ($("#tipBox").length == 0) { $("body").append('<div id="tipBox"></div>'); } else { $("#tipBox").show(); }
        var tagOff = tag.offset() || tag.position(), the = $("#tipBox");
        the.html('<div>' + msg + '</div>')
        var h = the.height() + 30;
        var _direction = direction || "up";
        if (leftplus == null) { leftplus = 0 }
        if (topplus == null) { topplus = 0 }
        if (_direction == "up") {
            the.css({ top: tagOff.top - h - 20, left: tagOff.left + leftplus }).removeClass("downTip leftTip rightTip");
            the.fadeIn(300).animate({ top: tagOff.top - h + topplus }, 300);
        } else if (_direction == "down") {
            the.css({ top: tagOff.top + tag.outerHeight() + 10, left: tagOff.left + leftplus }).addClass("downTip");
            the.fadeIn(300).animate({ top: tagOff.top + tag.outerHeight() + topplus }, 300);
        } else if (_direction == "left") {
            the.css({ top: tagOff.top + topplus, left: tagOff.left - tag.outerWidth() - 10 }).addClass("leftTip");
            the.fadeIn(300).animate({ left: tagOff.left - tag.outerWidth() - 10 + leftplus }, 300);
        } else if (_direction == "right") {
            the.css({ top: tagOff.top + topplus, left: tagOff.left + tag.outerWidth() + 10 + leftplus }).addClass("rightTip");
            the.fadeIn(300).animate({ left: tagOff.left + tag.outerWidth() + 10 + leftplus }, 300);
        }
        if (timer != -1) {
            the.hover(function () { clearTimeout(TipMsg.showTimer); }, function () {
                TipMsg.showTimer = setTimeout(function () {
                    the.fadeOut(300, function () { the.remove(); });
                }, timer);
            });
            TipMsg.showTimer = setTimeout(function () {
                the.fadeOut(300, function () { the.remove(); });
            }, timer);
        }
    },
    Dialog: function (icon, msg, timer) {/*true或false,"提示",时间*/
        var cName = icon == true ? "true" : "false";
        $("body").append('<div id="mark"></div><div id="automsg"><i class="' + cName + '"></i><span>' + msg + '</span></div>');
        var win = $(window), the = $("#automsg");
        the.css({ left: (win.width() - the.width()) / 2, top: (win.height() - the.height()) / 2 });
        setTimeout(function () { $("#mark,#automsg").remove(); }, timer);
    }
};

//======================来源网址
function getUrlParam(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return '/'; }


/*验证银行卡号*/
//银行卡号校验
//Description:  银行卡号Luhm校验
//Luhm校验规则：16位银行卡号（19位通用）:
// 1.将未带校验位的 15（或18）位卡号从右依次编号 1 到 15（18），位于奇数位号上的数字乘以 2。
// 2.将奇位乘积的个十位全部相加，再加上所有偶数位上的数字。
// 3.将加法和加上校验位能被 10 整除。
function bankcardCheck(bankno) {
    if (bankno.length < 16 || bankno.length > 19) {
        //$("#banknoInfo").html("银行卡号长度必须在16到19之间");
        return false;
    }
    var num = /^\d*$/;  //全数字
    if (!num.exec(bankno)) {
        //$("#banknoInfo").html("银行卡号必须全为数字");
        return false;
    }
    //开头6位
    var strBin = "10,18,30,35,37,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,58,60,62,65,68,69,84,87,88,94,95,98,99";
    if (strBin.indexOf(bankno.substring(0, 2)) == -1) {
        //$("#banknoInfo").html("银行卡号开头6位不符合规范");
        return false;
    }

    var lastNum = bankno.substr(bankno.length - 1, 1);//取出最后一位（与luhm进行比较）
    var first15Num = bankno.substr(0, bankno.length - 1);//前15或18位
    var newArr = new Array();
    for (var i = first15Num.length - 1; i > -1; i--) {    //前15或18位倒序存进数组
        newArr.push(first15Num.substr(i, 1));
    }
    var arrJiShu = new Array();  //奇数位*2的积 <9
    var arrJiShu2 = new Array(); //奇数位*2的积 >9
    var arrOuShu = new Array();  //偶数位数组
    for (var j = 0; j < newArr.length; j++) {
        if ((j + 1) % 2 == 1) {//奇数位
            if (parseInt(newArr[j]) * 2 < 9)
                arrJiShu.push(parseInt(newArr[j]) * 2);
            else
                arrJiShu2.push(parseInt(newArr[j]) * 2);
        }
        else //偶数位
            arrOuShu.push(newArr[j]);
    }
    var jishu_child1 = new Array();//奇数位*2 >9 的分割之后的数组个位数
    var jishu_child2 = new Array();//奇数位*2 >9 的分割之后的数组十位数
    for (var h = 0; h < arrJiShu2.length; h++) {
        jishu_child1.push(parseInt(arrJiShu2[h]) % 10);
        jishu_child2.push(parseInt(arrJiShu2[h]) / 10);
    }
    var sumJiShu = 0; //奇数位*2 < 9 的数组之和
    var sumOuShu = 0; //偶数位数组之和
    var sumJiShuChild1 = 0; //奇数位*2 >9 的分割之后的数组个位数之和
    var sumJiShuChild2 = 0; //奇数位*2 >9 的分割之后的数组十位数之和
    var sumTotal = 0;
    for (var m = 0; m < arrJiShu.length; m++) {
        sumJiShu = sumJiShu + parseInt(arrJiShu[m]);
    }
    for (var n = 0; n < arrOuShu.length; n++) {
        sumOuShu = sumOuShu + parseInt(arrOuShu[n]);
    }
    for (var p = 0; p < jishu_child1.length; p++) {
        sumJiShuChild1 = sumJiShuChild1 + parseInt(jishu_child1[p]);
        sumJiShuChild2 = sumJiShuChild2 + parseInt(jishu_child2[p]);
    }
    //计算总和
    sumTotal = parseInt(sumJiShu) + parseInt(sumOuShu) + parseInt(sumJiShuChild1) + parseInt(sumJiShuChild2);
    //计算Luhm值
    var k = parseInt(sumTotal) % 10 == 0 ? 10 : parseInt(sumTotal) % 10;
    var luhm = 10 - k;
    if (lastNum == luhm) {
        //$("#banknoInfo").html("Luhm验证通过");
        return true;
    }
    else {
        //$("#banknoInfo").html("银行卡号必须符合Luhm校验");
        return false;
    }
}
//==========================验证身份证
function ValidateIdCard(sId) {
    var aCity = { 11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古", 21: "辽宁", 22: "吉林", 23: "黑龙江 ", 31: "上海", 32: "江苏", 33: "浙江", 34: "安徽", 35: "福建", 36: "江西", 37: "山东", 41: "河南", 42: "湖北 ", 43: "湖南", 44: "广东", 45: "广西", 46: "海南", 50: "重庆", 51: "四川", 52: "贵州", 53: "云南", 54: "西藏 ", 61: "陕西", 62: "甘肃", 63: "青海", 64: "宁夏", 65: "新疆", 71: "台湾", 81: "香港", 82: "澳门", 91: "国外 " }
    var iSum = 0;
    var info = "";
    sId = sId.replace(/x$/i, "a");
    if (aCity[parseInt(sId.substr(0, 2))] == null) { return false };
    sBirthday = sId.substr(6, 4) + "-" + Number(sId.substr(10, 2)) + "-" + Number(sId.substr(12, 2));
    var d = new Date(sBirthday.replace(/-/g, "/"))
    if (sBirthday != (d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate())) { return false };
    for (var i = 17; i >= 0; i--) iSum += (Math.pow(2, i) % 11) * parseInt(sId.charAt(17 - i), 11)
    if (iSum % 11 != 1) { return false };
    return true;
}
//======================登录状态(获取用户信息)================
var login_status = function () {
    $.post(check_login_url, { action: "loginstatus", t: new Date() }, function (data) {
        if (data.user_id > 0) {
            $("#loginout").hide();
            $("#loginin").show();
            $("#userout").hide();
            $("#userin").show();
            $("#Hiddenid").val(data.items.id);
            $("#Hiddenphone").val(data.items.phone_mobile);
            $("#Hiddenname").val(data.items.username);
            $(".phone_mobile").html("您好，" + data.items.phone_mobile);
        } else {
            $("#loginout").show();
            $("#loginin").hide();
            $("#userout").show();
            $("#userin").hide();
        }
    });
}

var validatereferenceflag = false;
function validatereferencepc(id) {
    //只要数组组合url : "../user/user!validateRefrence.action?referencephone="+ $("#"+id).val(),
    //var reg=/^(1[2-9][0-9]|15[0|3|6|7|8|9]|18[8|9])\d{8}$/;
    var reg = /^\d{1,}$/;

    if (($("#" + id).val() == "" || $("#" + id).val() == null)) {
        if (id == "regreference") {
            $("#msg" + id).text("请输入代理商ID，如果没有，请致电客服：400-998-7778");
            validatereferenceflag = false;
        } else {
            $("#msg" + id).text("");
            validatereferenceflag = true;
        }

    } else if (reg.test($("#" + id).val())) {
        $("#msg" + id).text("");
        $.ajax({
            type: "post",
            async: false,
            url: "/tools/user_ajax.ashx?action=validateRefrence&referencephone=" + $("#" + id).val(),
            dataType: 'JSON',
            success: function (result) {

                if (result == true) {
                    validatereferenceflag = true;
                    $("#msg" + id).hide();

                } else {
                    $("#msg" + id).text("代理商不存在");
                    $("#msg" + id).show();
                    validatereferenceflag = false;

                }
            }
        });

    } else {
        $("#msg" + id).text("代理商ID不合法");
        $("#msg" + id).show();
        validatereferenceflag = false;

    }
    return validatereferenceflag;
}

var validatetvery = false;// 验证码是否正确
function validatetveryd(id) {
    var v = $("#" + id).val();
    if (v == null || v == "") {
        $("#msg" + id).text("请输入验证码");
        validatetvery = false;
        return false;
    } else {
        $.ajax({
            type: "post",
            url: '/tools/user_ajax.ashx?action=checkSessionKeyValue&key=randtvery&flag=reg&type=1&value=' + v,
            dataType: 'JSON',
            async: false,
            success: function (result) {
                if (result == true) {
                    $("#msg" + id).text("");
                    validatetvery = true;
                    return validatetvery;
                }
                else {
                    $("#msg" + id).text("验证码错误，请重新输入");
                    validatetvery = false;
                    return validatetvery;
                }
            }
        });
    }
}

codedata.validatecodeflag = false; //验证码是否合法

function validatecodepcregist(type, id, _this) {

    var mobile;
    var code = $("#" + id).val();

    if (code == "" || code == null || code.length < 1) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入验证码");
        $(_this).focus();
        codedata.validatecodeflag = false;
        return false;
    }

    $(".error-msg").hide();

    var url = "../member/verify_code_ajax?value=" + code + "&type=" + type + "&flag=reg&key=" + mobile;
    $.get(url, function (data) {

        if (data == "true" || data == true) {

            $(".error-msg").hide();
            codedata.validatecodeflag = true;
            return codedata.validatecodeflag;
        } else {
            $(".error-msg").show();
            $(".error-msg").find("span").text("验证码错误，请重新输入");

            $("#" + id).focus();
            codedata.validatecodeflag = false;
            return codedata.validatecodeflag;
        }
    });

}
codedata.phonecodeflag = false;
function vphonecodepcregist(type, id1, id2, id3, _this) {

    var mobile = $("#" + id3).val();
    if (mobile == "" || mobile == null) {
        mobile = $("#" + id3).attr("data-tel");
    }
    var code = $(_this).val();

    if (mobile == null || mobile == "") {

        $(".error-msg").show();
        $(".error-msg").find("span").text("手机号码不能为空");
        $("#" + id3).focus();
        codedata.phonecodeflag = false;
        return false;
    }
    var reg = /^\d{11}$/;
    if (!reg.test(mobile)) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("手机号格式不合法");
        $("#" + id3).focus();
        codedata.phonecodeflag = false;
        return false;
    }

    if (!codedata.validatecodeflag) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入验证码");
        $("#" + id1).focus();
        codedata.phonecodeflag = false;
        return false;
    }

    if (code == "" || code == null || code.length < 1) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入验证码");
        $(_this).focus();
        codedata.phonecodeflag = false;
        return false;
    }



    $(".error-msg").hide();

    var url = "../member/mobile_code_ajax?value=" + code + "&type=" + type + "&flag=reg&key=" + mobile;
    $.get(url, function (data) {

        if (data == "true" || data == true) {

            $(".error-msg").hide();
            codedata.phonecodeflag = true;
            return codedata.phonecodeflag;
        } else {
            $(".error-msg").show();
            $(".error-msg").find("span").text("验证码错误，请重新输入");

            $(_this).focus();
            codedata.phonecodeflag = false;
            return codedata.phonecodeflag;
        }
    });

}

//修改手机号码
function phonenext(id1, id2) {
    if (!codedata.validatecodeflag) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入验证码");
        $("#" + id1).focus();
        codedata.validatecodeflag = false;
        return false;
    }
    if (!codedata.phonecodeflag) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入验证码");
        $("#" + id2).focus();
        codedata.phonecodeflag = false;
        return false;
    }

    codedata.validatecodeflag = false;
    codedata.phonecodeflag = false;
    $("#modifytelphoneDialogfisrt").hide();
    $("#modifytelphoneDialogNext").show();

}

function btphonenext(odlphoneid, newphoneid, code1id, smcodeid) {
    var oldphone = $("#" + odlphoneid).attr("data-tel");
    var newphone = $("#" + newphoneid).val();
    var code = $("#" + code1id).val();
    var smcode = $("#" + smcodeid).val();

    if (newphone == null || newphone == "") {

        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入新手机号码");
        $("#" + newphoneid).focus();
        codedata.phonecodeflag = false;
        return false;
    }
    var reg = /^\d{11}$/;
    if (!reg.test(newphone)) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("手机号格式不合法");
        $("#" + newphoneid).focus();
        codedata.phonecodeflag = false;
        return false;
    }


    if (!codedata.validatecodeflag) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入验证码");
        $("#" + code1id).focus();
        codedata.validatecodeflag = false;
        return false;
    }
    if (!codedata.phonecodeflag) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的验证码");
        $("#" + smcodeid).focus();
        codedata.phonecodeflag = false;
        return false;
    }

    $(".error-msg").hide();
    $.ajax({
        type: "post",
        url: "/tools/user_ajax.ashx?action=editPhone&oldphone=" + oldphone + "&newphone=" + newphone + "&code=" + code + "&smcode=" + smcode + "",
        dataType: 'JSON',
        beforeSend: function () {
            layer.load("请求修改中.......", 3);
        },
        error: function (result) {
            layer.alert(result.responseText + "，请联系客服处理！", 8);
        },
        success: function (result) {

            layer.close();
            if (result.status == "y") {
                layer.alert(result.info, 9, function () {
                    location.reload();
                });
            }
            else {
                layer.alert(result.info, 8);

            }
        }
    });

}

//修改登录密码

function editloginpwd(phoneid, codeid, pwdid, _this) {
    var phone = $("#" + phoneid).attr("data-tel");
    var pwd = $("#" + pwdid).val();
    var code = $("#" + codeid).val();

    if (!codedata.phonecodeflag) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的验证码");
        $("#" + smcodeid).focus();
        codedata.phonecodeflag = false;
        return false;
    }
    //codedata.validatecodeflag= false;
    // codedata.phonecodeflag = false;
    $(".error-msg").hide();
    $.ajax({
        type: "post",
        url: "/tools/user_ajax.ashx?action=editLoginPwdnew&phone=" + phone + "&newpwds=" + pwd + "&smcode=" + code + "",
        dataType: 'JSON',
        beforeSend: function () {
            layer.load("请求修改中.......", 3);
        },
        error: function (result) {
            layer.alert(result.responseText + "，请联系客服处理！", 8);
        },
        success: function (result) {

            layer.close();
            if (result.status == "y") {
                layer.alert(result.info, 9, function () {
                    location.reload();
                });
            }
            else {
                layer.alert(result.info, 8);

            }
        }
    });

}


//设置提款密码
function setNickname(nicknameid, _this) {
    var nickname = $("#" + nicknameid).val();


    if (nickname == "" | nickname == null) {
        // layer.alert("密码不能为空");
        $(".error-msg").show();
        $(".error-msg").find("span").text("新昵称不能为空");
        $("#" + nicknameid).focus();
        return;
    }
    $(".error-msg").hide();
    $.ajax({
        type: "post",
        url: "/tools/user_ajax.ashx?action=editNickname&nickname=" + nickname + "",
        dataType: 'JSON',
        beforeSend: function () {
            layer.load("请求修改中.......", 3);
        },
        error: function (result) {
            layer.alert(result.responseText + "，请联系客服处理！", 8);
        },
        success: function (result) {

            layer.close();
            if (result.status == "y") {
                layer.alert(result.info, 9, function () {
                    location.reload();
                });
            }
            else {
                layer.alert(result.info, 8);

            }
        }
    });

}

//设置提款密码
function setpasspwd(id1, id2, _this) {
    var pwd1 = $("#" + id1).val();
    var pwd2 = $("#" + id2).val();
    if (pwd1 == "" | pwd1 == null) {
        // layer.alert("密码不能为空");
        $(".error-msg").show();
        $(".error-msg").find("span").text("密码不能为空");
        $("#" + id1).focus();
        return;
    }
    if (pwd1.length < 6) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("密码位数不能低于6位");
        //  layer.alert("密码位数不能低于6位");
        $("#" + id1).focus();
        return;
    }
    if (pwd2 == "" | pwd2 == null) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请再次输入密码");
        // layer.alert("请再次输入密码");
        $("#" + id2).focus();
        return;
    }
    if (pwd1 != pwd2) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("两次密码不一致");
        //layer.alert("两次密码不一致");
        $("#" + id2).focus();
        return;
    }
    $(".error-msg").hide();
    $.ajax({
        type: "post",
        url: "/tools/user_ajax.ashx?action=setTradepass&pwd1=" + pwd1 + "&pwd2=" + pwd2 + "",
        dataType: 'JSON',
        beforeSend: function () {
            layer.load("请求修改中.......", 3);
        },
        error: function (result) {
            layer.alert(result.responseText + "，请联系客服处理！", 8);
        },
        success: function (result) {

            layer.close();
            if (result.status == "y") {
                layer.alert(result.info, 9, function () {
                    location.reload();
                });
            }
            else {
                layer.alert(result.info, 8);

            }
        }
    });

}
//updatepasspwd('_oldpasspwd','_newpasspwd1','_newpasspwd2'this)
//修改提款密码
function updatepasspwd(oldid, id1, id2, _this) {

    var oldpwd = $("#" + oldid).val();
    var pwd1 = $("#" + id1).val();
    var pwd2 = $("#" + id2).val();

    if (oldpwd == "" | oldid == null) {
        // layer.alert("密码不能为空");
        $(".error-msg").show();
        $(".error-msg").find("span").text("原密码不能为空");
        $("#" + oldid).focus();
        return;
    }
    if (oldpwd.length < 6) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("原密码不正确");
        //  layer.alert("密码位数不能低于6位");
        $("#" + oldid).focus();
        return;
    }
    if (pwd1 == "" | pwd1 == null) {
        // layer.alert("密码不能为空");
        $(".error-msg").show();
        $(".error-msg").find("span").text("密码不能为空");
        $("#" + id1).focus();
        return;
    }
    if (pwd1.length < 6) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("密码位数不能低于6位");
        //  layer.alert("密码位数不能低于6位");
        $("#" + id1).focus();
        return;
    }
    if (pwd2 == "" | pwd2 == null) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请再次输入密码");
        // layer.alert("请再次输入密码");
        $("#" + id2).focus();
        return;
    }
    if (pwd1 != pwd2) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("两次密码不一致");
        //layer.alert("两次密码不一致");
        $("#" + id2).focus();
        return;
    }
    $(".error-msg").hide();
    $.ajax({
        type: "post",
        url: "/tools/user_ajax.ashx?action=changeTradepass&pwd1=" + pwd1 + "&pwd2=" + pwd2 + "&oldpwd=" + oldpwd + "",
        dataType: 'JSON',
        beforeSend: function () {
            layer.load("请求修改中.......", 3);
        },
        error: function (result) {
            layer.alert(result.responseText + "，请联系客服处理！", 8);
        },
        success: function (result) {

            layer.close();
            if (result.status == "y") {
                layer.alert(result.info, 9, function () {
                    location.reload();
                });
            }
            else {
                layer.alert(result.info, 8);

            }
        }
    });

}


//发送支付验证码
function sendVricode(_this, id1, id2) {


    var token = $("#hidentoken").val();
    var orderId = $("#hidenorderId").val();

    $.ajax({
        type: "post",
        url: "/tools/user_opt_ajax.ashx?act=sendVercode&token=" + token + "&orderId=" + orderId + "&t=" + Math.random(4),
        dataType: 'JSON',
        beforeSend: function () {
            layer.load("验证码发送中.......", 3);
        },
        error: function (result) {
            layer.alert(result.responseText + "，请联系客服处理！", 8);
        },
        success: function (result) {

            layer.close();
            if (result.status == "y") {
                refreshmsg(id1, 60, id2);
            }
            else {
                layer.alert(result.info, 8);

            }
        }
    });

}


//发送验证码

function getcodephoneregpc(_type, phoneid, codeid, id1, id2) {
    var mobile;
    if (_type == 1) {
        mobile = $("#" + phoneid).attr("data-tel");

    } else {
        mobile = $("#" + phoneid).val();
    }

    var code = $("#" + codeid).val();

    if (mobile == null || mobile == "") {

        if (_type == 1) {
            $(".error-msg").show();
            $(".error-msg").find("span").text("您未绑定手机或登录已失效");

        } else {
            $(".error-msg").show();
            $(".error-msg").find("span").text("手机号码不能为空");
            $("#" + phoneid).focus();

        }
        return false;
    }
    var reg = /^\d{11}$/;
    if (!reg.test(mobile)) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("手机号格式不合法");
        $("#" + phoneid).focus();

        return false;
    }
    if (code == "" || code == null || code.length < 1) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入验证码");
        $("#" + codeid).focus();

        return false;
    }

    if (!codedata.validatecodeflag) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的验证码");
        $("#" + codeid).focus();
        return false;
    }

    $(".error-msg").hide();

    $.ajax({
        type: "post",
        url: "/tools/user_ajax.ashx?action=smsSend&code2=" + code + "&mobile=" + mobile + "&registname=phoneMobile&flag=1",
        dataType: 'JSON',
        beforeSend: function () {
            layer.load("验证码发送中.......", 3);
        },
        error: function (result) {
            layer.alert(result.responseText + "，请联系客服处理！", 8);
        },
        success: function (result) {

            layer.close();
            if (result.status == "y") {
                refreshmsg(id1, 60, id2);
            }
            else {
                layer.alert(result.info, 8);

            }
        }
    });


}



//发送注册验证码

function getregcodephoneregpc(_type, phoneid, codeid, id1, id2) {
    var mobile;
    if (_type == 1) {
        mobile = $("#" + phoneid).attr("data-tel");

    } else {
        mobile = $("#" + phoneid).val();
    }

    var code = $("#" + codeid).val();

    if (mobile == null || mobile == "") {

        if (_type == 1) {
            $(".error-msg").show();
            $(".error-msg").find("span").text("您未绑定手机或登录已失效");

        } else {
            $(".error-msg").show();
            $(".error-msg").find("span").text("手机号码不能为空");
            $("#" + phoneid).focus();

        }
        return false;
    }
    var reg = /^\d{11}$/;
    if (!reg.test(mobile)) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("手机号格式不合法");
        $("#" + phoneid).focus();

        return false;
    }
    if (code == "" || code == null || code.length < 1) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入验证码");
        $("#" + codeid).focus();

        return false;
    }

    if (!codedata.validatecodeflag) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的验证码");
        $("#" + codeid).focus();
        return false;
    }

    $(".error-msg").hide();

    $.ajax({
        type: "post",
        url: "/tools/user_ajax.ashx?action=smsSendReg&code2=" + code + "&mobile=" + mobile + "&registname=phoneMobile&flag=1",
        dataType: 'JSON',
        beforeSend: function () {
            layer.load("验证码发送中.......", 3);
        },
        error: function (result) {
            layer.alert(result.responseText + "，请联系客服处理！", 8);
        },
        success: function (result) {

            layer.close();
            if (result.status == "y") {
                refreshmsg(id1, 60, id2);
            }
            else {
                layer.alert(result.info, 8);

            }
        }
    });


}


function refreshmsg(id, t, bid) {
    if (t > 0) {
        t--;
        addCookie("refreshid", id, 4)//刷新的id
        addCookie("refresht", t, 4)//刷新的时间
        addCookie("refreshbid", bid, 4)//刷新的时间
        setTimeout("refreshmsg('" + id + "'," + t + ",'" + bid + "');", 1000);
        $("#" + bid).text("过" + t + "秒后重新获取");
        $("#" + bid).show();
        $("#" + id).hide();
    } else {
        $("#" + id).show();
        $("#" + bid).hide();
    }
}

//validatephoneflag = false;
function validatephonepc() {
    var phoneno = $("#phoneno").val();
    //var reg=/^(1[2-9][0-9]|15[0|3|6|7|8|9]|18[8|9])\d{8}$/;
    var reg = /^\d{11}$/;
    //var reg = /^(((13[0-9]{1})|(15[0-9]{1}))+\d{8})$/;
    if (phoneno == null || phoneno == "") {
        $("#phonenomsg").text("手机号码不能为空");
        $("#phonenomsg").show();
        validatephoneflag = false;
        return false;
    } else {
        if (reg.test(phoneno)) {
            $("#phonenomsg").text("");
            var url = "/tools/user_ajax.ashx?action=check_phone&valivalue="
					+ $("#phoneno").val();
            $.get(url, function (data) {


                if (data == "true") {
                    $("#phonenomsg").text("该手机号已注册，请重新输入手机号码");

                    validatephoneflag = false;
                    return validatephoneflag;

                } else {
                    $("#phonenomsg").text("");
                    validatephoneflag = true;
                    return validatephoneflag;
                }
            });
        } else {
            $("#phonenomsg").text("请输入正确的手机号码");
            //$("#phoneno").val("");
            $("#phonenomsg").show();
            validatephoneflag = false;
            return false;
        }
    }
}



function vallidatepwdpc(id) {
    var v = $("#" + id).val();

    var reg = /^[0-9a-zA-Z]*$/;//字母和数字的组合 
    if (v == "" || v.length < 6) {
        $("#msg" + id).text("请输入至少6位密码");
        $("#msg" + id).show();
        return false;
    } else {
        if (reg.test(v)) {
            $("#msg" + id).text(" ");
            if (v.length < 7) {
                $("#phonesecuritylv").html("密码强度：<span class=\"s1\">弱</span><span class=\"s2\">中</span><span class=\"s2\">强</span>");
                $("#emailsecuritylv").html("密码强度：<span class=\"s1\">弱</span><span class=\"s2\">中</span><span class=\"s2\">强</span>");
            } else if (v.length < 10) {
                $("#phonesecuritylv").html("密码强度：<span class=\"s2\">弱</span><span class=\"s1\">中</span><span class=\"s2\">强</span>");
                $("#emailsecuritylv").html("密码强度：<span class=\"s2\">弱</span><span class=\"s1\">中</span><span class=\"s2\">强</span>");
            } else {
                $("#phonesecuritylv").html("密码强度：<span class=\"s2\">弱</span><span class=\"s2\">中</span><span class=\"s1\">强</span>");
                $("#emailsecuritylv").html("密码强度：<span class=\"s2\">弱</span><span class=\"s2\">中</span><span class=\"s1\">强</span>");
            }

            return true;
        } else {
            $("#msg" + id).text("密码格式不正确！");
            $("#msg" + id).show();
            return false;
        }
    }
}



//重复密码
function vallidaterepwdpc(id) {
    var v = $("#" + id).val();
    if (v != $("#pwd").val()) {
        $("#msg" + id).text("两次输入密码不一致");
        $("#msg" + id).show();
        //$("#" + id).val("");
        return false;
    } else {
        $("#msg" + id).text("");
        return true;
    }
}


//======================切换验证码
function ToggleCode(obj, codeurl) { $(obj).attr("src", codeurl + "?time=" + Math.random()); }

//找回密码

function findpwd(_phoneno2, _code2, _code_mobile2, _findpwd1, _findpwd2, _this) {
    var mobile = $("#" + _phoneno2).val(), pwd = $("#" + _findpwd1).val(), pwd2 = $("#" + _findpwd2).val(), code_mobile = $("#" + _code_mobile2).val(), code = $("#" + _code2).val();

    if (mobile == "" || mobile == null) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("手机号码不能为空");
        $("#" + _phoneno2).focus();
        return false;
    }
    var reg = /^\d{11}$/;
    if (!reg.test(mobile)) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("手机号码格式不正确");
        $("#" + _phoneno2).focus();
        return false;
    }
    if (code == null || code == "") {

        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入验证码");
        $("#" + _code2).focus();
        return false;
    }
    if (code.length < 1) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的验证码");

        $("#" + _code2).focus();
        return false;
    }
    if (!codedata.validatecodeflag) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的验证码");
        $("#" + _code2).focus();
        return false;
    }
    if (!codedata.phonecodeflag) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的短信验证码");
        $("#" + _code_mobile2).focus();
        return false;
    }

    if (pwd == null || pwd == "") {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入新密码");

        $("#" + _findpwd1).focus();
        return false;
    }
    if (pwd.length < 6) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入至少6位密码");

        $("#" + _findpwd1).focus();
        return false;
    }

    if (pwd2 == null || pwd2 == "") {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入确认密码");

        $("#" + _findpwd2).focus();
        return false;
    }
    if (pwd != pwd2) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("两次密码输入不一致");

        $("#" + _findpwd2).focus();
        return false;
    }

    $(".error-msg").hide();
    $.ajax({
        type: "POST",
        url: '../member/findpwd_ajax',
        dataType: "json",
        data: { "mobile": mobile, "pwd1": pwd, "pwd2": pwd2, phoneVerification: code_mobile, code: code },
        timeout: 20000,
        cache: false,
        beforeSend: function (XMLHttpRequest) {
            $("#regbutton").attr("disabled", true);
            var loadi = layer.load('正在验证，请稍后...');

        },
        success: function (data, textStatus) {
            layer.close();
            if (data.status == "y") {
                //layer.alert(data.info, 1);
                layer.alert("重置密码成功", 9, function () {
                    window.location.href = "../Index/login";
                });

            } else {
                layer.alert(data.info, 8);
                $("#regbutton").attr("disabled", false);

            }

        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            layer.close();
            alert("状态：" + textStatus + "；出错提示：" + errorThrown);
            $("#regbutton").attr("disabled", false);

        }
    });
}


//找回提款密码

function findtrasspwd(_phoneno2, _code2, _code_mobile2, _findpwd1, _findpwd2, _this) {
    var mobile = $("#" + _phoneno2).val(), pwd = $("#" + _findpwd1).val(), pwd2 = $("#" + _findpwd2).val(), code_mobile = $("#" + _code_mobile2).val(), code = $("#" + _code2).val();

    if (mobile == "" || mobile == null) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("手机号码不能为空");
        $("#" + _phoneno2).focus();
        return false;
    }
    var reg = /^\d{11}$/;
    if (!reg.test(mobile)) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("手机号码格式不正确");
        $("#" + _phoneno2).focus();
        return false;
    }
    if (code == null || code == "") {

        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入验证码");
        $("#" + _code2).focus();
        return false;
    }
    if (code.length < 1) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的验证码");

        $("#" + _code2).focus();
        return false;
    }
    if (!codedata.validatecodeflag) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的验证码");
        $("#" + _code2).focus();
        return false;
    }
    if (!codedata.phonecodeflag) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的短信验证码");
        $("#" + _code_mobile2).focus();
        return false;
    }

    if (pwd == null || pwd == "") {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入新密码");

        $("#" + _findpwd1).focus();
        return false;
    }
    if (pwd.length < 6) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入至少6位密码");

        $("#" + _findpwd1).focus();
        return false;
    }

    if (pwd2 == null || pwd2 == "") {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入确认密码");

        $("#" + _findpwd2).focus();
        return false;
    }
    if (pwd != pwd2) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("两次密码输入不一致");

        $("#" + _findpwd2).focus();
        return false;
    }

    $(".error-msg").hide();
    $.ajax({
        type: "POST",
        url: '/tools/user_ajax.ashx?action=trade_pwd_reset&' + Math.random(),
        dataType: "json",
        data: { "mobile": mobile, "pwd1": pwd, "pwd2": pwd2, phoneVerification: code_mobile, code: code },
        timeout: 20000,
        cache: false,
        beforeSend: function (XMLHttpRequest) {
            $(_this).attr("disabled", true);
            var loadi = layer.load('正在验证，请稍后...');

        },
        success: function (data, textStatus) {
            layer.close();
            if (data.status == "y") {
                //layer.alert(data.info, 1);
                layer.alert("重置密码成功", 9, function () {
                    location.reload();
                });

            } else {
                layer.alert(data.info, 8);
                $(_this).attr("disabled", false);

            }

        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            layer.close();
            alert("状态：" + textStatus + "；出错提示：" + errorThrown);
            $(_this).attr("disabled", false);

        }
    });
}

// 注册

function reg(phoneno, code1, code_mobile1, pwd1, _this, error_msg1, _nickname, newRfeence2) {
    var mobile = $("#" + phoneno).val(), pwd = $("#" + pwd1).val(), code_mobile = $("#" + code_mobile1).val(), code = $("#" + code1).val(), nickname = $("#" + _nickname).val();;
    var refid = 0;

    var _agents_id = getUrlParam("agents_id");
    var _staff_id = getUrlParam("staff_id");
    try {
        refid = $("#refid").val();
    } catch (e) {

    }

    if (mobile == "" || mobile == null) {

        $("." + error_msg1).show();
        $("." + error_msg1).find("span").text("手机号码不能为空");
        $("#" + phoneno).focus();
        return false;
    }
    var reg = /^\d{11}$/;
    if (!reg.test(mobile)) {

        $("." + error_msg1).show();
        $("." + error_msg1).find("span").text("手机号码格式不正确");
        $("#" + phoneno).focus();
        return false;
    }
    if (code == null || code == "") {

        $("." + error_msg1).show();
        $("." + error_msg1).find("span").text("请输入验证码");
        $("#" + code).focus();
        return false;
    }
    if (code.length < 1) {
        $("." + error_msg1).show();
        $("." + error_msg1).find("span").text("请输入正确的验证码");

        $("#" + code1).focus();
        return false;
    }
    if (code_mobile == null || code_mobile == "") {

        $("." + error_msg1).show();
        $("." + error_msg1).find("span").text("请输入短信验证码");
        $("#" + code_mobile).focus();
        return false;
    }



    // if (!codedata.validatecodeflag) {
    //     $(".error-msg").show();
    //     $(".error-msg").find("span").text("请输入正确的验证码");
    //     $("#" + code1).focus();
    //     return false;
    // }
    // if (!codedata.phonecodeflag) {
    //     $(".error-msg").show();
    //     $(".error-msg").find("span").text("请输入正确的短信验证码");
    //     $("#" + code_mobile1).focus();
    //     return false;
    // }
    if (nickname.length < 2) {

        $("." + error_msg1).show();
        $("." + error_msg1).find("span").text("请设置昵称");

        $("#" + _nickname).focus();
        return false;
    }

    if (pwd == null || pwd == "") {
        $("." + error_msg1).show();
        $("." + error_msg1).find("span").text("请设置密码");

        $("#" + pwd1).focus();
        return false;
    }

    if (pwd.length < 6) {
        $("." + error_msg1).show();
        $("." + error_msg1).find("span").text("请输入至少6位密码");

        $("#" + code_mobile).focus();
        return false;
    }
    var newRfeence = "";
    if (!(parseFloat(_agents_id) > 0 || parseFloat(_staff_id) > 0 || parseFloat(refid) > 0)) {

        newRfeence = $("#" + newRfeence2).val();
        //if (newRfeence == "" || newRfeence == null) {

        //    $(".error-msg").show();
        //    $(".error-msg").find("span").text("必须填写推荐码，如不知道请联系客服");
        //    $("#" + newRfeence2).focus();

        //    return;
        //}
        if (newRfeence != "" && newRfeence != null) {
            if (newRfeence.indexOf('A') == -1 || newRfeence.indexOf('B') == -1 || newRfeence.indexOf('C') == -1) {
                $(".error-msg").show();
                $(".error-msg").find("span").text("推荐码格式不正确，如有不明白请联系客服");
                $("#newRfeence").focus();
                return;
            }
        }

    }
    $(".modal-error").hide();
    $(".error-msg").hide();
    $.ajax({
        type: "POST",
        url: '../member/reg_ajax.html',
        dataType: "json",
        data: { "phoneMobile": mobile, "loginPass": pwd, phoneVerification: code_mobile, code: code, reference: refid, "nickname": nickname, "agents_id": _agents_id, "staff_id": _staff_id, "newRfeence": newRfeence },
       // data: { "phoneMobile": mobile, "loginPass": pwd, phoneVerification: code_mobile, code: code, reference: refid, "nickname": nickname, "agents_id": _agents_id, "staff_id": _staff_id},
        //timeout: 20000,
        cache: false,
        beforeSend: function (XMLHttpRequest) {
            $(_this).attr("disabled", true);
            layer.load('正在注册，请稍候...');

        },
        success: function (data, textStatus) {
            layer.closeAll();
            if (data.status == "y") {
                layer.alert(data.info, 9, function () {
                    window.location.href = user_center_url;
                });

            } else {

                $("." + error_msg1).show();
                $("." + error_msg1).find("span").text(data.info);
                $(_this).attr("disabled", false);

            }

        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            layer.closeAll();
            alert("状态：" + textStatus + "；出错提示：" + errorThrown);
            $(_this).attr("disabled", false);

        }
    });

}
// 退出登录
function loginout() {
    $.ajax({
        url: '/tools/user_ajax.ashx?action=loginout&' + Math.random(),
        beforeSend: function (XMLHttpRequest) {
            layer.load("正在注销...");
            $("#btloginout").attr("disabled", true);
        },
        success: function (data, textStatus) {
            layer.close();
            location.reload();
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            layer.close();
            layer.alert("状态：" + textStatus + "；出错提示：" + errorThrown, $("#btnSubmit"));
            $("#btloginout").attr("disabled", false);
        }
    });
}


//登录
function login(type, mobile, password, _this) {
    var url = getUrlParam("url"), mobile = $("#" + mobile).val(), pwd = $("#" + password).val(), rb_name = 0;

    if (mobile == null || mobile == "") {
        //$(".error-msg").show();
        //$(".error-msg").find("span").text("手机号码不能为空");
        layer.alert("手机号码不能为空");
        $("#" + mobile).focus();
        return false;
    }
    var reg = /^\d{11}$/;
    if (!reg.test(mobile)) {
        //$(".error-msg").show();
        //$(".error-msg").find("span").text("手机号格式不合法");
        layer.alert("手机号格式不合法");
        $("#" + mobile).focus();
        return false;
    }
    if (pwd == null || pwd == "") {
        //$(".error-msg").show();
        //$(".error-msg").find("span").text("请输入密码");
        layer.alert("请输入密码");
        $("#" + password).focus();
        return false;
    }
    if (pwd.length < 6) {
        //$(".error-msg").show();
        //$(".error-msg").find("span").text("请输入正确的密码");
        layer.alert("请输入正确的密码");
        $("#" + password).focus();
        return false;
    }
    $(".error-msg").hide();

    $.ajax({
        type: "POST",
        url: login_url,
        dataType: "json",
        data: { "mobile": mobile, "pwd": pwd },
        timeout: 20000,
        cache: false,
        beforeSend: function (XMLHttpRequest) {
            layer.load("正在登录中...");
            $(_this).attr("disabled", true);
        },
        success: function (data, textStatus) {
            layer.close();

            if (data.status == "y") {
                //  layer.alert(data.info, 9);

                if (type == 1 || type == "1") {
                    if (new RegExp('/login.html').test(String(window.location.pathname)) || new RegExp('/register.html').test(String(window.location.pathname))) {
                        location.href = user_center_url;
                        return;
                    }
                    location.reload();//弹出层登陆
                } else {
                    location.href = user_center_url;
                }
            } else {
                layer.alert(data.info, 8);
                $(_this).attr("disabled", false);

            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            layer.close();
            layer.alert("状态：" + textStatus + "；出错提示：" + errorThrown, $("#btnSubmit"));
            $(_this).attr("disabled", false);
        }
    });
}

//=======================转账回执单
var bankRecharge = function () {
    var off_bank_name = $("#off_bank_name").val(), yh = $("#yh").val(), total = $("#total").val(), remark = $("#remark").val();


    if (total == "" || isNaN(total)) {
        $("#bannkrechargemoney").focus();
        // TipMsg.position("转账金额只能是数字！", $("#bannkrechargemoney"), 2000, 0, 0);
        layer.alert("转账金额只能是数字！", 8);
        return;
    }

    layer.load("提交中...");
    $.ajax({
        url: "/tools/user_opt_ajax.ashx?act=bankRecharge",
        dataType: "text",
        contentType: "application/x-www-form-urlencoded;charset=utf-8",
        type: "post",
        timeout: 6000,
        data: $("#form3").serialize(),
        success: function (data) {
            layer.closeAll();
            var obj = eval('(' + data + ')');
            if (obj.status == "y") {
                layer.alert(obj.info, 9, function () {
                    window.location.reload();
                });
            }
            else {
                layer.alert(obj.info, 8);
                return;
            }
        }
    });
}

//=======================微信充值
var WechartRecharge = function () {
    var rechargemoney = $("#wechat_total").val();

    if (rechargemoney == "" || isNaN(rechargemoney)) {
        $("#wechatrechargemoney").focus();
        // TipMsg.position("转账金额只能是数字！", $("#bannkrechargemoney"), 2000, 0, 0);
        layer.alert("转账金额只能是数字！", 8);
        return;
    }
    layer.load("提交中...");
    $.ajax({
        url: "/tools/user_opt_ajax.ashx?act=wenchartRecharge",
        dataType: "text",
        contentType: "application/x-www-form-urlencoded;charset=utf-8",
        type: "post",
        timeout: 6000,
        data: $("#form4").serialize(),
        success: function (data) {
            layer.closeAll();
            var obj = eval('(' + data + ')');
            if (obj.status == "y") {
                showDialog("#tipDialog");
                //layer.alert(obj.info, 9, function () {
                //    window.location.reload();
                //});
            }
            else {
                layer.alert(obj.info, 8);
                return;
            }
        }
        ,
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            layer.closeAll();
            layer.alert("状态：" + textStatus + "；出错提示：" + errorThrown + "");

        }
    });
}

//=======================支付宝充值
var ZFBRecharge = function () {
    var rechargemoney = $("#zfb_total").val();

    if (rechargemoney == "" || isNaN(rechargemoney)) {
        $("#wechatrechargemoney").focus();
        // TipMsg.position("转账金额只能是数字！", $("#bannkrechargemoney"), 2000, 0, 0);
        layer.alert("转账金额只能是数字！", 8);
        return;
    }
    layer.load("提交中...");
    $.ajax({
        url: "/tools/user_opt_ajax.ashx?act=ajaxAlipayReplay",
        dataType: "text",
        contentType: "application/x-www-form-urlencoded;charset=utf-8",
        type: "post",
        timeout: 6000,
        data: $("#form5").serialize(),
        success: function (data) {
            layer.closeAll();
            var obj = eval('(' + data + ')');
            if (obj.status == "y") {

                showDialog("#tipDialog");
                //layer.alert(obj.info, 9, function () {
                //    window.location.reload();
                //});
            }
            else {
                layer.alert(obj.info, 8);
                return;
            }
        }
        ,
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            layer.closeAll();
            layer.alert("状态：" + textStatus + "；出错提示：" + errorThrown + "");

        }
    });
}

//=======================在线充值
var rechargeOnline = function () {


    var rechargemoney = $("#rechargemoney").val(), payid = $('#bankcode').val();


    if (isNaN(rechargemoney)) {
        $("#rechargemoney").focus();
        //TipMsg.position("充值金额必须是数字！", $("#rechargemoney"), 2000, 0, 0);

        layer.alert("充值金额必须是数字！", 8);

        return;
    }
    //if (rechargemoney < 1) {
    //    $("#rechargemoney").focus();
    //    //  TipMsg.position("充值金额必须大于1元！", $("#rechargemoney"), 2000, 0, 0);
    //    layer.alert("充值金额必须大于1元！", 8);
    //    return;
    //}

    window.open("/api/pay/unspay/index.aspx?amount=" + rechargemoney + "&bankCode=" + payid, "_blank");
    showDialog("#rechargeDialog");
}
//=======================添加银行卡
function addBank() {
    $("#hprovince").val($("#provincecode").find("option:selected").text());
    $("#hcity").val($("#citycode").find("option:selected").text());
    $("#BankName").val($("#BankCode").find("option:selected").text());
    var BankCode = $("#BankCode").val(), BankName = $("#BankName").val(), provincecode = $("#provincecode").val(),
        citycode = $("#citycode").val(), upbankname = $("#upbankname").val(),
        changbankno1 = $("#changbankno").val(), changbankno2 = $("#changbankno2").val();
    if (BankCode == "-1") {
        $("#BankCode").focus();
        //TipMsg.position("请选择开户银行！", $("#BankCode"), 2000, 0, 0);
        layer.alert("请选择开户银行！", 8);
        return;
    }
    if (provincecode == "-1") {
        $("#provincecode").focus();
        //TipMsg.position("请选择开户银行！", $("#BankCode"), 2000, 0, 0);
        layer.alert("请选择开户银行所在省！", 8);
        return;
    }
    if (citycode == "-1") {
        $("#citycode").focus();
        //TipMsg.position("请选择开户银行！", $("#BankCode"), 2000, 0, 0);
        layer.alert("请选择开户银行所在市！", 8);
        return;
    }
    if (upbankname == "") {
        $("#upbankname").focus();
        // TipMsg.position("请输入开户支行！", $("#upbankname"), 2000, 0, 0);
        layer.alert("请输入开户支行！", 8);
        return;
    }

    if (changbankno1 == "" || changbankno1 == null) {
        $("#changbankno").focus();
        layer.alert("请输入银行卡号！", 8);
        return;
    }
    if (!bankcardCheck(changbankno1)) {
        $("#changbankno").focus();
        // TipMsg.position("银行卡号格式不正确！", $("#changbankno"), 2000, 0, 0);
        layer.alert("银行卡号格式不正确！", 8);
        return;
    }
    if (changbankno2 == "" || changbankno2 == null) {
        $("#changbankno2").focus();
        layer.alert("请再次确认银行卡号！", 8);
        return;
    }
    if (changbankno1 != changbankno2) {
        $("#changbankno2").focus();
        layer.alert("两次输入不一致，请重新输入！", 8);
        return;
    }
    $.ajax({
        url: "/tools/user_opt_ajax.ashx?act=addbank",
        dataType: "text",
        contentType: "application/x-www-form-urlencoded;charset=utf-8",
        type: "post",
        timeout: 6000,
        data: $("#form1").serialize(),
        success: function (data) {
            var obj = eval('(' + data + ')');
            if (obj.status == "y") {
                layer.alert(obj.info, 9, function () {

                    location.href = "/member/setting.html";
                });

            }
            else {
                //  TipMsg.position(obj.info, $("#btnAddBank"), 2000, 30, 0);
                layer.alert(obj.info, 8);
                return;
            }
        }
    });
}
//=======================删除银行卡
var delBank = function () {
    var bankid = $("#bankid").val();
    if (bankid == "0") {
        $("#btnbankid").focus();
        // TipMsg.position("请选择需要删除的银行卡！", $("#btnbankid"), 2000, 0, 0);
        layer.alert("请选择需要删除的银行卡！", 8);
        return;
    }
    layer.confirm('您确认要删除该银行卡吗？', {
        btn: ['确定', '取消'] //按钮
    }, function () {
        $.ajax({
            url: "/tools/user_opt_ajax.ashx?act=delbank&bankid=" + bankid,
            dataType: "text",
            contentType: "application/x-www-form-urlencoded;charset=utf-8",
            type: "post",
            timeout: 6000,
            success: function (data) {
                var obj = eval('(' + data + ')');
                if (obj.status == "y") {
                    layer.alert(obj.info);
                    window.location.href = "/user/withdrawal.html?ask=3";
                }
                else {
                    layer.alert(obj.info, 8);
                    return;
                }
            }
        });
    });

}
//=======================我要提款
var withdrawal = function () {


    var tkyhk = $("#tkyhk").val(), cash_money = $("#cash_money").val(), available_balance_money = $("#cash_money").attr("maxvalue"),
        trade_pass = $("#trade_pass").val();
    if (isNaN(cash_money)) {
        $("#cash_money").focus();
        //TipMsg.position("提款金额必须是数字！", $("#cash_money"), 2000, 0, 0);
        layer.alert("提款金额必须是数字！", 8);
        return;
    }
    if (cash_money < 1) {
        $("#cash_money").focus();
        //TipMsg.position("提款金额必须大于1元！", $("#cash_money"), 2000, 0, 0);
        layer.alert("提款金额必须大于1元！", 8);
        return;
    }
    if (parseInt(cash_money) > parseInt(available_balance_money)) {
        $("#cash_money").focus();
        //TipMsg.position("提款金额不能大于账户余额！", $("#cash_money"), 2000, 0, 0);
        layer.alert("提款金额不能大于账户余额！", 8);
        return;
    }
    if (tkyhk == "") {
        $("#tkyhk").focus();
        // TipMsg.position("请选择提款银行卡！", $("#tkyhk"), 2000, 0, 0);
        layer.alert("请选择提款银行卡！", 8);
        return;
    }
    if (trade_pass == "") {
        $("#trade_pass").focus();
        //TipMsg.position("请输入交易密码！", $("#trade_pass"), 2000, 0, 0);
        layer.alert("请输入交易密码！", 8);
        return;
    }
    $.ajax({
        url: "/tools/user_opt_ajax.ashx?act=withdrawal",
        dataType: "text",
        contentType: "application/x-www-form-urlencoded;charset=utf-8",
        type: "post",

        data: $("#form2").serialize(),
        beforeSend: function (XMLHttpRequest) {
            layer.load("正在提交申请...");
            $("#btloginout").attr("disabled", true);
        },
        success: function (data) {
            layer.closeAll();
            var obj = eval('(' + data + ')');
            if (obj.status == "y") {

                layer.alert("您申请的提现已成功，工作日9:00-16:00提现，银行当日结算，t+2个工作日内到账，具体到账时间以银行到账时间为准。 ", 9, function () {
                    window.location.href = "/member/drawings.html?ask=2";
                });
            }
            else {
                //TipMsg.position(obj.info, $("#btnwithdrawal"), 2000, 30, 0);
                layer.alert(obj.info, 8);
                return;
            }
        },
        error: function (xhr) {

            layer.closeAll();

        }
    });
}


//=======================修改用户信息
function user_opt() {
    $("#hprovince").val($("#provincecode").find("option:selected").text());
    $("#hcity").val($("#citycode").find("option:selected").text());
    $.ajax({
        url: "/tools/user_opt_ajax.ashx?act=opt",
        dataType: "text",
        contentType: "application/x-www-form-urlencoded;charset=utf-8",
        type: "post",
        timeout: 6000,
        data: $("#form1").serialize(),
        success: function (data) {
            var obj = eval('(' + data + ')');
            if (obj.status == "y") {
                window.location.reload();
                return;
            }
            else {
                // TipMsg.position(obj.info, $("#btn_reset"), 2000, 30, 0);
                layer.alert(obj.info, 8);
                return;
            }
        }
    });
}

/**
 * 判断金额框是否输入的是合法的数字
 * @returns {boolean}
 */
function validateMoney(a) {
    var reNum = /^(([1-9]\d*)|0)(\.(\d){1,2})?$/;
    if (!reNum.test($(a).val())) {
        $(a).val("");
    } else {
        if (parseFloat($(a).val()) > parseFloat($(a).attr("maxValue"))) {
            $(a).val($(a).attr("maxValue"));
        }
    }
}


/*======================我的充值记录==============================*/
function user_rechargeCallback(page_id) {
    user_rechargeData(page_id);
}
function user_rechargeData(pageindx) {
    var stime = $("#txtStime").val(), etime = $("#txtEndtime").val(), rechargeType = $("#rechargeType").val();
    var listcount = $("#user_recharge_count").val();
    $.get("/tools/user_opt_ajax.ashx", { act: "user_recharge_list", "stime": stime, "etime": etime, "rechargeType": rechargeType, p: (pageindx + 1), t: new Date() }, function (data) {
        if (listcount <= 10) {
            $("#pager_user_recharge").css("display", "none");
        } else {
            $("#pager_user_recharge").css("display", "block");
        }
        var obj = eval('(' + data + ')');
        if (obj.info.length > 16) {
            $("#user_recharge_list").html(obj.info);
        } else {
            $("#user_recharge_list").html("<tr><td colspan='8' style='text-align: center'>暂无记录</td></tr>");
        }
    });
    $("#pager_user_recharge").pagination(listcount, {
        callback: user_rechargeCallback,
        prev_text: '上一页',
        next_text: '下一页',
        items_per_page: 10,
        num_display_entries: 2,
        current_page: pageindx,
        num_edge_entries: 1
    });
}

/*======================我的会员==============================*/
function user_referenceCallback(page_id) {
    user_referenceData(page_id);
}
function user_referenceData(pageindx) {
    var stime = $("#txtrfStime").val(), etime = $("#txtrfEndtime").val();
    var listcount = $("#user_reference_count").val();
    $.get("/tools/user_opt_ajax.ashx", { act: "user_reference_list", "stime": stime, "etime": etime, p: (pageindx + 1), t: new Date() }, function (data) {
        if (listcount <= 10) {
            $("#pager_user_reference").css("display", "none");
        } else {
            $("#pager_user_reference").css("display", "block");
        }
        if (data.length > 16) {
            $("#juc-users-data").html(data);
        } else {
            $("#juc-users-data").html("<tr><td colspan='3' style='text-align: center'>暂无记录</td></tr>");
        }
    });
    $("#pager_user_reference").pagination(listcount, {
        callback: user_referenceCallback,
        prev_text: '上一页',
        next_text: '下一页',
        items_per_page: 10,
        num_display_entries: 2,
        current_page: pageindx,
        num_edge_entries: 1
    });
}


/*======================我的投资列表==============================*/
function user_borrowCallback(page_id) {
    user_borrowData(page_id);
}
function user_borrowData(pageindx) {
    var stime = $("#txtStime").val(), etime = $("#txtEndtime").val(), productType = $("#productType").val();
    var listcount = $("#user_borrow_count").val();
    $.get("/tools/user_opt_ajax.ashx", { act: "user_borrow_list", "stime": stime, "etime": etime, "productType": productType, p: (pageindx + 1), t: new Date() }, function (data) {
        if (listcount <= 10) {
            $("#pager_user_borrow").css("display", "none");
        } else {
            $("#pager_user_borrow").css("display", "block");
        }
        var obj = eval('(' + data + ')');
        if (obj.info.length > 16) {
            $("#user_borrow_list").html(obj.info);
        } else {
            $("#user_borrow_list").html("<tr><td colspan='8' style='text-align: center'>暂无记录</td></tr>");
        }
    });
    $("#pager_user_borrow").pagination(listcount, {
        callback: user_borrowCallback,
        prev_text: '上一页',
        next_text: '下一页',
        items_per_page: 10,
        num_display_entries: 2,
        current_page: pageindx,
        num_edge_entries: 1
    });
}
/*======================我的提款记录==============================*/
function user_cashCallback(page_id) {
    user_cashData(page_id);
}
function user_cashData(pageindx) {
    var stime = $("#txtStime").val(), etime = $("#txtEndtime").val();
    var listcount = $("#user_cash_count").val();
    $.get("/tools/user_opt_ajax.ashx", { act: "user_cash_list", "stime": stime, "etime": etime, p: (pageindx + 1), t: new Date() }, function (data) {
        var obj = eval('(' + data + ')');
        listcount = obj.count;
        if (listcount <= 10) {
            $("#pagination-drawing").css("display", "none");
        } else {
            $("#pagination-drawing").css("display", "block");
        }

        if (obj.info.length > 16) {
            $("#drawing_list").html(obj.info);
        } else {
            $("#drawing_list").html("<tr><td colspan='5' style='text-align: center'>暂无记录</td></tr>");
        }
    });
    $("#pagination-drawing").pagination(listcount, {
        callback: user_cashCallback,
        prev_text: '上一页',
        next_text: '下一页',
        items_per_page: 10,
        num_display_entries: 2,
        current_page: pageindx,
        num_edge_entries: 1
    });
}

//=======================资金查询
function money_all() {
    $.get("/tools/user_opt_ajax.ashx", { act: "user_money_all", t: new Date() }, function (data) {
        var obj = eval('(' + data + ')');
        $(".money_total").html(obj.money_total);
        $(".borrow_money").html(obj.borrow_money);
        $(".user_deposit_money").html(obj.user_deposit_money);
        $(".lock_money").html(obj.lock_money);
        $(".available_balance_money").html(obj.available_balance_money);
        $(".lend_money").html(obj.lend_money);
    });
}



/*======================会员资金明细==============================*/
function user_moneyCallback(page_id) {
    user_moneyData(page_id);
}
function user_moneyData(pageindx) {
    var stime = $("#txtStime").val(), etime = $("#txtEndtime").val(), service_type = $("#serviceType").val();
    var listcount = $("#user_money_count").val();
    $.get("/tools/user_opt_ajax.ashx", { act: "user_money_list", "service_type": service_type, "stime": stime, "etime": etime, p: (pageindx + 1), t: new Date() }, function (data) {
        if (listcount <= 10) {
            $("#pager_user_money").css("display", "none");
        } else {
            $("#pager_user_money").css("display", "block");
        }
        var obj = eval('(' + data + ')');
        $("#moneycount").html(obj.count);
        $("#money_pay").html(obj.money_pay);
        $("#money_get").html(obj.money_get);
        if (obj.count > 0) {
            $("#user_money_list").html(obj.info);
        } else {
            $("#user_money_list").html("<div class='tr' style='text-align:center;height: 42px;line-height: 42px;'>暂无记录</div>");
        }
        $(".detailstab .xq1").click(function () {
            $(this).parent().parent().parent().find(".xq2").show();
            $(this).parent().parent().parent().find(".xq1").hide();
            $(this).parent().parent().parent().find(".xqbox").show();
            $(".detailstab .xq2").click(function () {
                $(".xq1").show();
                $(".xq2").hide();
                $(".xqbox").hide();
            });
        });
    });
    $("#pager_user_money").pagination(listcount, {
        callback: user_moneyCallback,
        prev_text: '上一页',
        next_text: '下一页',
        items_per_page: 10,
        num_display_entries: 2,
        current_page: pageindx,
        num_edge_entries: 1
    });
}


//=======================修改登录密码
function changePwd() {
    var _oldpwd = $.trim($("#oldPwd").val());
    var _newPwd1 = $.trim($("#newPwd1").val());
    var _newPwd2 = $.trim($("#newPwd2").val());

    if (!ValidateChar(_oldpwd)) {
        $("#oldPwd").focus();
        layer.alert("密码由6-24位的字母数字或下划线组成！", 8);
        return;
    }
    if (!ValidateChar(_newPwd1)) {
        $("#newPwd1").focus();
        layer.alert("密码由6-24位的字母数字或下划线组成！", 8);
        return;
    }
    if (_newPwd1 != "" && _newPwd1 != _newPwd2) {
        layer.alert("两次输入密码不一致", 8); $("#newPwd2").focus(); return;
    }
    $.ajax({
        url: "/tools/user_opt_ajax.ashx?act=reset_pwd",
        dataType: "text",
        type: "post",
        timeout: 6000,
        async: false,
        data: $("#form1").serialize(),
        success: function (data) {
            var obj = eval('(' + data + ')');
            if (obj.status == "old") {
                TipMsg.position("旧密码不正确", $("#oldPwd"), 2000, 30, 0); $("#oldPwd").focus(); return;
            }
            else {
                TipMsg.position(obj.info, $("#subChange"), 2000, 30, 0); return;
            }
        }
    });
}

//=======================修改交易密码
function changepwd_tra() {
    var _newPwd1 = $.trim($("#tnewPwd1").val());
    var _newPwd2 = $.trim($("#tnewPwd2").val());

    if (!ValidateChar(_newPwd1)) {
        $("#tnewPwd1").focus();
        TipMsg.position("交易密码由6-24位的字母数字或下划线组成！", $("#tnewPwd1"), 2000, 0, 0);
        return;
    }
    if (_newPwd1 != "" && _newPwd1 != _newPwd2) {
        TipMsg.position("两次输入密码不一致", $("#tnewPwd2"), 2000, 0, 0); $("#tnewPwd2").focus(); return;
    }

    $.ajax({
        url: "/tools/user_opt_ajax.ashx?act=trade_pwd",
        dataType: "text",
        type: "post",
        timeour: 6000,
        async: false,
        data: $("#form1").serialize(),
        success: function (data) {
            var obj = eval('(' + data + ')');
            if (obj.status == "y") {
                window.location.reload();
            }
            else {
                TipMsg.position(obj.info, $("#btn_tradepass"), 2000, 30, 0); return;
            }
        }
    });
}

//=======================修改交易密码2
function changepwd_tra_2() {
    var t_pwd_login = $.trim($("#t_pwd_login").val()), t_id_no = $.trim($("#t_id_no").val()),
        t_trade_pwd_1 = $.trim($("#t_trade_pwd_1").val()), t_trade_pwd_2 = $.trim($("#t_trade_pwd_2").val()),
        t_trade_code = $.trim($("#t_trade_code").val());

    if (!ValidateChar(t_pwd_login)) {
        $("#t_pwd_login").focus();
        TipMsg.position("登录密码错误！", $("#t_pwd_login"), 2000, 0, 0);
        return;
    }

    /*身份证验证*/
    if (!ValidateIdCard(t_id_no)) {
        $("#t_id_no").focus();
        TipMsg.position("请输入正确的身份证号码！", $("#t_id_no"), 2000, 0, 0);
        return;
    }

    if (!ValidateChar(t_trade_pwd_1)) {
        $("#t_trade_pwd_1").focus();
        TipMsg.position("交易密码由6-24位的字母数字或下划线组成！", $("#t_trade_pwd_1"), 2000, 0, 0);
        return;
    }

    if (t_trade_pwd_1 != "" && t_trade_pwd_1 != t_trade_pwd_2) {
        TipMsg.position("两次交易密码不一致", $("#t_trade_pwd_2"), 2000, 0, 0); $("#t_trade_pwd_2").focus(); return;
    }

    if (t_trade_code.length != 4) {
        $("#t_trade_code").focus();
        TipMsg.position("请输入正确的短信验证码！", $("#t_trade_code"), 2000, 0, 0);
        return;
    }

    $.ajax({
        url: "/tools/user_opt_ajax.ashx?act=trade_pwd_2",
        dataType: "text",
        type: "post",
        timeour: 6000,
        async: false,
        data: $("#form1").serialize(),
        success: function (data) {
            var obj = eval('(' + data + ')');
            if (obj.status == "y") {
                alert(obj.info);
                window.location.reload();
            }
            else {
                TipMsg.position(obj.info, $("#changepwd_tra"), 2000, 30, 0); return;
            }
        }
    });
}
//实名认证
function validateName() {
    var _realName = $("#realName").val();
    var _idCard = $("#idCard").val();
    if (_realName == "" || _realName == null) {
        $(".modal-error").show();
        $(".modal-error").text("请输入姓名");
        $("#realName").focus();
        return;
    }

    var reg = /^[\u4e00-\u9fa5]{2,10}$/i;
    if (!reg.test(_realName)) {
       
        $(".modal-error").show();
        $(".modal-error").text("姓名只能为汉字，且不能有空格和特殊字符");
        $("#realName").focus();
        return;
    }

    if (_idCard == "" || _idCard == null) {
        $(".modal-error").show();
        $(".modal-error").text("请输入身份证号码");
        $("#idCard").focus();
        return;
    }

    if (!ValidateIdCard(_idCard)) {
        $(".modal-error").show();
        $(".modal-error").text("请输入正确的身份证号码");
        return;
    }

    $(".modal-error").hide();


    var url = "/tools/user_ajax.ashx?action=validateIdNo&idno=" + _idCard + "&name=" + _realName + "";
    var url1 = encodeURI(encodeURI(url));
    $.ajax({
        type: "post",
        url: url1,
        dataType: 'JSON',
        beforeSend: function () {
            layer.load("实名认证中,请稍等.....");
        },
        success: function (result) {
            layer.close();
            if (result.status == "y") {
                layer.alert(result.info, 9, function () {
                    window.location.reload(true);
                });
            }
            else {
                layer.alert(result.info, 8);
            }
        }
    });

}
/*验证身份证*/
function ValidateIdCard(sId) {
    var aCity = { 11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古", 21: "辽宁", 22: "吉林", 23: "黑龙江 ", 31: "上海", 32: "江苏", 33: "浙江", 34: "安徽", 35: "福建", 36: "江西", 37: "山东", 41: "河南", 42: "湖北 ", 43: "湖南", 44: "广东", 45: "广西", 46: "海南", 50: "重庆", 51: "四川", 52: "贵州", 53: "云南", 54: "西藏 ", 61: "陕西", 62: "甘肃", 63: "青海", 64: "宁夏", 65: "新疆", 71: "台湾", 81: "香港", 82: "澳门", 91: "国外 " }
    var iSum = 0;
    var info = "";
    sId = sId.replace(/x$/i, "a");
    if (aCity[parseInt(sId.substr(0, 2))] == null) { return false };
    sBirthday = sId.substr(6, 4) + "-" + Number(sId.substr(10, 2)) + "-" + Number(sId.substr(12, 2));
    var d = new Date(sBirthday.replace(/-/g, "/"))
    if (sBirthday != (d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate())) { return false };
    for (var i = 17; i >= 0; i--) iSum += (Math.pow(2, i) % 11) * parseInt(sId.charAt(17 - i), 11)
    if (iSum % 11 != 1) { return false };
    return true;
}
//领取优惠券

function getcoupl(_this, couponCode, copon_error) {
    var _couponCode = $("#" + couponCode).val();

    if (_couponCode == null || _couponCode == "") {
        $("#" + copon_error).show();
        $("#" + copon_error).find("span").text("优惠券码不能为空");
        $("#" + couponCode).focus();
        return;
    } else {
        $("#" + copon_error).hide();
    }

    $.ajax({
        type: "post",
        url: "/tools/user_opt_ajax.ashx?act=free_Coupon&code=" + _couponCode + "",
        dataType: 'JSON',
        beforeSend: function () {
            layer.load("优惠券领取中,请稍等.....");

            $(_this).attr("disabled", true);
        },
        success: function (result) {
            $(_this).attr("disabled", false);
            layer.close();
            if (result.status == "y") {
                layer.alert(result.info, 9, function () {
                    window.location.reload(true);
                });
            }
            else {
                layer.alert(result.info, 8);
            }
        }
    });
    $(_this).attr("disabled", false);
}


//兑换积分
function exchangecoupl(_this, couponId) {
    var _id = $("#" + couponId).val();
    if (_id == "" || _id == null) {

        return;
    }

    $.ajax({
        type: "post",
        url: "/tools/user_opt_ajax.ashx?act=exchange_Coupon&id=" + _id + "",
        dataType: 'JSON',
        beforeSend: function () {
            layer.load("优惠券兑换中,请稍等.....");

            $(_this).attr("disabled", true);
        },
        success: function (result) {
            $(_this).attr("disabled", false);
            layer.close();
            if (result.status == "y") {
                layer.alert(result.info, 9, function () {
                    window.location.reload(true);
                });
            }
            else {
                layer.alert(result.info, 8);
            }
        }
    });
    $(_this).attr("disabled", false);
}

//弹出层部分


function regnext(onestep, twostep, _this, phoneno, code1, code_mobiles) {
    var mobile = $("#" + phoneno).val(), code_mobile = $("#" + code_mobiles).val(), code = $("#" + code1).val();
    if (mobile == "" || mobile == null) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("手机号码不能为空");
        $("#" + phoneno).focus();
        return false;
    }
    var reg = /^\d{11}$/;
    if (!reg.test(mobile)) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("手机号码格式不正确");
        $("#" + phoneno).focus();
        return false;
    }
    if (code == null || code == "") {

        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入验证码");
        $("#" + code1).focus();
        return false;
    }
    if (code.length < 1) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的验证码");

        $("#" + code1).focus();
        return false;
    }
    if (code_mobile == null || code_mobile == "") {

        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入短信验证码");
        $("#" + code_mobiles).focus();
        return false;
    }


    if (!codedata.validatecodeflag) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的验证码");
        $("#" + code1).focus();
        return false;
    }
    if (!codedata.phonecodeflag) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的短信验证码");
        $("#" + code_mobiles).focus();
        return false;
    }
    $(".error-msg").hide();
    $("#" + onestep).hide();
    $("#" + twostep).show();

}

function regok(regpwd1, regpwd2, ts, phoneno, code1, code_mobiles, _this, _nickname, newRfeence2) {
    var pw1 = $("#" + regpwd1).val();
    var pw2 = $("#" + regpwd2).val();


    var mobile = $("#" + phoneno).val(), code_mobile = $("#" + code_mobiles).val(), code = $("#" + code1).val(), nickname = $("#" + _nickname).val();
    if (mobile == "" || mobile == null) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("手机号码不能为空");
        $("#" + phoneno).focus();
        $("#" + onestep).show();
        $("#" + twostep).hide();
        return false;
    }
    var reg = /^\d{11}$/;
    if (!reg.test(mobile)) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("手机号码格式不正确");
        $("#" + phoneno).focus();
        $("#" + onestep).show();
        $("#" + twostep).hide();
        return false;
    }
    if (code == null || code == "") {

        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入验证码");
        $("#" + code1).focus();
        $("#" + onestep).show();
        $("#" + twostep).hide();
        return false;
    }
    if (code.length < 1) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的验证码");

        $("#" + code1).focus();
        $("#" + onestep).show();
        $("#" + twostep).hide();
        return false;
    }
    if (code_mobile == null || code_mobile == "") {

        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入短信验证码");
        $("#" + code_mobiles).focus();
        $("#" + onestep).show();
        $("#" + twostep).hide();
        return false;
    }


    if (!codedata.validatecodeflag) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的验证码");
        $("#" + code1).focus();
        $("#" + onestep).show();
        $("#" + twostep).hide();
        return false;
    }
    if (!codedata.phonecodeflag) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的短信验证码");
        $("#" + code_mobiles).focus();
        $("#" + onestep).show();
        $("#" + twostep).hide();
        return false;
    }
    if (nickname == "" || nickname == null) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入昵称");
        $("#" + _nickname).focus();
        return false;
    }

    if (pw1 == "" || pw1 == null) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("密码不能为空");
        $("#" + regpwd1).focus();
        return false;
    }

    if (pw1.length < 6) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("密码不能小于6位");
        $("#" + regpwd1).focus();
        return false;
    }
    if (pw2 == "" || pw2 == null) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入确认密码");
        $("#" + regpwd2).focus();
        return false;
    }
    if (pw2 != pw1) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("两次密码不匹配，请重新输入");
        $("#" + regpwd2).focus();
        return false;
    }
    $(".error-msg").hide();
    this.reg('regphone', 'regivccode1', 'phoneverifyCode', regpwd1, _this, 'error-msg', _nickname, newRfeence2);
}

function forgetone(phoneno, code1, code_mobiles, _this, forgetone, forgettwo) {
    var mobile = $("#" + phoneno).val(), code_mobile = $("#" + code_mobiles).val(), code = $("#" + code1).val();
    if (mobile == "" || mobile == null) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("手机号码不能为空");
        $("#" + phoneno).focus();
        return false;
    }
    var reg = /^\d{11}$/;
    if (!reg.test(mobile)) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("手机号码格式不正确");
        $("#" + phoneno).focus();
        return false;
    }
    if (code == null || code == "") {

        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入验证码");
        $("#" + code1).focus();
        return false;
    }
    if (code.length < 1) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的验证码");

        $("#" + code1).focus();
        return false;
    }
    if (code_mobile == null || code_mobile == "") {

        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入短信验证码");
        $("#" + code_mobiles).focus();
        return false;
    }


    if (!codedata.validatecodeflag) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的验证码");
        $("#" + code1).focus();
        return false;
    }
    if (!codedata.phonecodeflag) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的短信验证码");
        $("#" + code_mobiles).focus();
        return false;
    }
    $(".error-msg").hide();
    $("#" + forgetone).hide();
    $("#" + forgettwo).show();

}

function forgetok(phoneno, code1, code_mobiles, _this, regpwd1, regpwd2, onestep, twostep) {


    var pw1 = $("#" + regpwd1).val();
    var pw2 = $("#" + regpwd2).val();


    var mobile = $("#" + phoneno).val(), code_mobile = $("#" + code_mobiles).val(), code = $("#" + code1).val();
    if (mobile == "" || mobile == null) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("手机号码不能为空");
        $("#" + phoneno).focus();
        $("#" + onestep).show();
        $("#" + twostep).hide();
        return false;
    }
    var reg = /^\d{11}$/;
    if (!reg.test(mobile)) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("手机号码格式不正确");
        $("#" + phoneno).focus();
        $("#" + onestep).show();
        $("#" + twostep).hide();
        return false;
    }
    if (code == null || code == "") {

        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入验证码");
        $("#" + code1).focus();
        $("#" + onestep).show();
        $("#" + twostep).hide();
        return false;
    }
    if (code.length < 1) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的验证码");

        $("#" + code1).focus();
        $("#" + onestep).show();
        $("#" + twostep).hide();
        return false;
    }
    if (code_mobile == null || code_mobile == "") {

        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入短信验证码");
        $("#" + code_mobiles).focus();
        $("#" + onestep).show();
        $("#" + twostep).hide();
        return false;
    }


    if (!codedata.validatecodeflag) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的验证码");
        $("#" + code1).focus();
        $("#" + onestep).show();
        $("#" + twostep).hide();
        return false;
    }
    if (!codedata.phonecodeflag) {
        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入正确的短信验证码");
        $("#" + code_mobiles).focus();
        $("#" + onestep).show();
        $("#" + twostep).hide();
        return false;
    }

    if (pw1 == "" || pw1 == null) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("密码不能为空");
        $("#" + regpwd1).focus();
        return false;
    }

    if (pw1.length < 6) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("密码不能小于6位");
        $("#" + regpwd1).focus();
        return false;
    }
    if (pw2 == "" || pw2 == null) {

        $(".error-msg").show();
        $(".error-msg").find("span").text("请输入确认密码");
        $("#" + regpwd2).focus();
        return false;
    }
    $(".error-msg").hide();
    this.findpwd(phoneno, code1, code_mobiles, regpwd1, regpwd2, _this);
}